< !DOCTYPE
html >
< html >
< head >
< title > DeepSeek本地大模型服务 < / title >
< style >
.container
{max - width: 800px;
margin: 0
auto;
padding: 20
px;}
.input - group
{margin - bottom: 15px;}
textarea
{width: 100 %;
height: 100
px;}
# response { white-space: pre-wrap; background: #f5f5f5; padding: 10px; }
< / style >
< / head >
< body >
< div


class ="container" >

< h1 > DeepSeek模型服务 < / h1 >

< div


class ="input-group" >

< h3 > 文件上传 < / h3 >
< input
type = "file"
id = "fileInput" >
< button
onclick = "uploadFile()" > 上传文件 < / button >
< div
id = "fileContent" > < / div >
< / div >

< div


class ="input-group" >

< h3 > 文本输入 < / h3 >
< textarea
id = "prompt"
placeholder = "输入您的问题..." > < / textarea >
< button
onclick = "submitQuery()" > 提交 < / button >
< div
id = "response" > < / div >
< / div >
< / div >

< script >
async function
submitQuery()
{
    const
prompt = document.getElementById('prompt').value;
const
response = await fetch('/api/chat', {
    method: 'POST',
    headers: {'Content-Type': 'application/json'},
    body: JSON.stringify({prompt})
});
const
data = await response.json();
document.getElementById('response').textContent = data.response;
}

async function
uploadFile()
{
    const
file = document.getElementById('fileInput').files[0];
const
formData = new
FormData();
formData.append('file', file);

const
response = await fetch('/api/upload', {
    method: 'POST',
    body: formData
});
const
data = await response.json();
document.getElementById('fileContent').textContent =
`文件内容摘要：${data.content}...
`;
}
< / script >
< / body >
< / html >
